using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class DownloadInfo
    {
		#region Local Variable
		public enum Field
		{
			ID,
			URL,
			DateTime,
			Name,
			NameVN,
			DecribesVN,
			Decribes,
			IDCategories
		}
		private Int32 _ID;
		private String _URL;
		private DateTime _DateTime;
		private String _Name;
		private String _NameVN;
		private String _DecribesVN;
		private String _Decribes;
		private Int32 _IDCategories;
		
		public Int32 ID{	get{ return _ID;} set{_ID = value;} }
		public String URL{	get{ return _URL;} set{_URL = value;} }
		public DateTime DateTime{	get{ return _DateTime;} set{_DateTime = value;} }
		public String Name{	get{ return _Name;} set{_Name = value;} }
		public String NameVN{	get{ return _NameVN;} set{_NameVN = value;} }
		public String DecribesVN{	get{ return _DecribesVN;} set{_DecribesVN = value;} }
		public String Decribes{	get{ return _Decribes;} set{_Decribes = value;} }
		public Int32 IDCategories{	get{ return _IDCategories;} set{_IDCategories = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public DownloadInfo()
		{
			_ID = 0;
			_URL = "";
			_DateTime = DateTime.Now;
			_Name = "";
			_NameVN = "";
			_DecribesVN = "";
			_Decribes = "";
			_IDCategories = 0;
		}
		public DownloadInfo(
		Int32 ID,
		String URL,
		DateTime DateTime,
		String Name,
		String NameVN,
		String DecribesVN,
		String Decribes,
		Int32 IDCategories
		)
		{
			_ID = ID;
			_URL = URL;
			_DateTime = DateTime;
			_Name = Name;
			_NameVN = NameVN;
			_DecribesVN = DecribesVN;
			_Decribes = Decribes;
			_IDCategories = IDCategories;
		}
		public DownloadInfo(DataRow dr)
		{
			if (dr != null)
			{
				_ID = dr[Field.ID.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.ID.ToString()]);
				_URL = dr[Field.URL.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.URL.ToString()]);
				_DateTime = dr[Field.DateTime.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.DateTime.ToString()]);
				_Name = dr[Field.Name.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Name.ToString()]);
				_NameVN = dr[Field.NameVN.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.NameVN.ToString()]);
				_DecribesVN = dr[Field.DecribesVN.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.DecribesVN.ToString()]);
				_Decribes = dr[Field.Decribes.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Decribes.ToString()]);
				_IDCategories = dr[Field.IDCategories.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.IDCategories.ToString()]);
			}
		}
		public DownloadInfo(DownloadInfo objEntr)
		{			
			_ID = objEntr.ID;			
			_URL = objEntr.URL;			
			_DateTime = objEntr.DateTime;			
			_Name = objEntr.Name;			
			_NameVN = objEntr.NameVN;			
			_DecribesVN = objEntr.DecribesVN;			
			_Decribes = objEntr.Decribes;			
			_IDCategories = objEntr.IDCategories;			
		}
        #endregion Constructor
        
        #region InitTable
		public DataTable ToDataTable()
		{
			DataTable dt = new DataTable("Download");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.ID.ToString(), typeof(Int32)),
				new DataColumn(Field.URL.ToString(), typeof(String)),
				new DataColumn(Field.DateTime.ToString(), typeof(DateTime)),
				new DataColumn(Field.Name.ToString(), typeof(String)),
				new DataColumn(Field.NameVN.ToString(), typeof(String)),
				new DataColumn(Field.DecribesVN.ToString(), typeof(String)),
				new DataColumn(Field.Decribes.ToString(), typeof(String)),
				new DataColumn(Field.IDCategories.ToString(), typeof(Int32))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.ID.ToString()] = _ID;
			row[Field.URL.ToString()] = _URL;
			row[Field.DateTime.ToString()] = _DateTime;
			row[Field.Name.ToString()] = _Name;
			row[Field.NameVN.ToString()] = _NameVN;
			row[Field.DecribesVN.ToString()] = _DecribesVN;
			row[Field.Decribes.ToString()] = _Decribes;
			row[Field.IDCategories.ToString()] = _IDCategories;
			return row;
		}
        #endregion InitTable
    }
}
